#include "../includes/OTHER_TYPES/ARRAY/CHAR/UTF16.h"

int main(int argc, char * argv[])
{  
  CHECK_SYS_ENDIAN();
  
  // https://en.wikipedia.org/wiki/UTF-16
  
  // array with UTF16BE encoded characters
  char real[20] = {0x00, 'b', 0x00, 'a', 0x00, 0x24, 0x00, '>', 0x20, 0xAC, 0xD8, 0x01, 0xDC, 0x37, 0xD8, 0x52, 0xDF, 0x62};
  for (int i = 0; i < 20; /**/)
  {
    print_enc_utf16be(&real[0] + i, 20 - i);
    printf(" ");
    if (check_enc_utf16be(&real[0] + i, 20 - i) == 0)
      break;
    i += check_enc_utf16be(&real[0] + i, 20 - i);
  }
  
  // testing write_utf16be_int()
  utf16_int test = 0x1096B3;
  printf("\n%02X %02X\n", 0x24, ((byte *) write_enc_utf16be(test, &real[0], 20) + 1)[0]);
  print_enc_utf16be(&real[0], 20);
  printf("\n");
  
  // array with UTF16LE encoded characters
  char real1[20] = {'b', 0x00, 'a', 0x00, 0x24, 0x00, '>', 0x00, 0xAC, 0x20, 0x01, 0xD8, 0x37, 0xDC, 0x52, 0xD8, 0x62, 0xDF};
  for (int i = 0; i < 20; /**/)
  {
    print_enc_utf16le(&real1[0] + i, 20 - i);
    printf(" ");
    if (check_enc_utf16le(&real1[0] + i, 20 - i) == 0)
      break;
    i += check_enc_utf16le(&real1[0] + i, 20 - i);
  }
  
  // testing write_enc_utf16le()
  printf("\n%02X %02X\n", 0x24, ((byte *) write_enc_utf16le(test, &real1[0], 20))[0]);
  print_enc_utf16le(&real1[0], 20);
  printf("\n");
  
  return 0;
}
